package com.zheng.rpc.controller;

import com.zheng.rpc.annotations.RpcReference;
import com.zheng.rpc.api.HelloService;
import com.zheng.rpc.entities.Hello;
import com.zheng.rpc.proxy.RpcClientProxy;
import com.zheng.rpc.remoting.transport.netty.client.NettyRpcClient;
import org.springframework.stereotype.Component;

import java.lang.reflect.Proxy;

@Component
public class HelloController {
    @RpcReference(version = "v1.0", group = "test")
    private HelloService helloService;

    public void test() throws InterruptedException {
        String hello = helloService.hello(new Hello("hello", "hello world"));
        //如需使用 assert 断言，需要在 VM options 添加参数：-ea
        //assert "Hello description is hello world".equals(hello);
        Thread.sleep(12000);
        for (int i = 0; i < 10; i++) {
            System.out.println(helloService.hello(new Hello("hello", "hello world")));
        }
    }
}
